<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SettlementWeight extends Model
{
    protected $table = 'settlement_weight';

    protected $primaryKey = 'system_number';

    protected $keyType = 'string';

    protected $fillable = [
    	'system_number',
    	'vehicle_number',
    	'driver_name',
    	'driver_idcard',
    	'driver_mobile_phone',
    	'actual_weight',
    	'system_datetime',
    	'is_weight',
    	'updae_datetime',
    	'operator'
    ];

    public $timestamps = false;

    protected $appends = [
        'is_weight_desc'
    ];

    const IS_WEIGHT_NO = 'N';

    const IS_WEIGHT_YES = 'Y';

    public static $IS_WEIGHT = [
        self::IS_WEIGHT_NO => '未过磅',
        self::IS_WEIGHT_YES => '已过磅'
    ];

    public function getIsWeightDescAttribute(){
        if(array_key_exists('is_weight', $this->attributes)){
            return $this->attributes['is_weight_desc'] = self::$IS_WEIGHT[$this->attributes['is_weight']];
        }
    }
}
